package cn.edu.lingnan.mapper;

import cn.edu.lingnan.user.dtos.ListStoresDto;
import cn.edu.lingnan.user.dtos.QuestionStoreDTO;
import cn.edu.lingnan.user.pojos.QuestionStore;
import cn.edu.lingnan.user.pojos.QuestionStoreType;
import cn.edu.lingnan.user.vos.QuestionStoreVO;
import cn.edu.lingnan.user.vos.QuestionWithOptionsVO;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface QuestionStoreMapper {

    Page<QuestionStore> selectStoresByUserId(ListStoresDto listStoresDto);

    int insertQuestionStore(QuestionStoreDTO dto);

    int updateQuestionStore(QuestionStore store);

    int deleteQuestionStore(@Param("storeId") Integer storeId);

    QuestionStoreVO selectStoreById(@Param("storeId") Integer storeId);


    List<QuestionWithOptionsVO> selectQuestionsWithOptions(@Param("storeId") Integer storeId);

    @Select("SELECT * FROM tb_exam_system.t_store_type")
    List<QuestionStoreType> selectStoreTypes();

    void updateUserQuestionBankImg(Long storeId, String img);

    void deleteQuestionByStoreId(Integer storeId);

    @Select("SELECT * FROM t_question_store WHERE store_id = #{storeId}")
    QuestionStore getStoreById(Integer storeId);

    @Select("SELECT store_id FROM t_question_store WHERE store_name LIKE CONCAT('%', #{storeName}, '%')")
    Integer getStoreLikeByName(String storeName);
}
